/**
 * Captain
 * © 2018 Captain copyright，All rights reserved.
 * http://www.sccaptain.com.cn
 * 
 * JAVA : 8
 * 文  件  名: ShoppingCartController.java
 * 创  建  人: QinYoubin (qin.youbin@sccaptain.com.cn)
 * 创建时间: 2018年5月2日 下午2:05:31
 * 版         本: 1.0.0
 * 备         注:
 * 修订历史:
 */
package com.material.c2c.web.shopping.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cpt.framework.web.JsonResult;
import com.material.c2c.shoping.entity.GWC;
import com.material.c2c.shoping.service.ShoppingCartService;
import com.material.c2c.web.util.ControllerUtil;

/**
 * 购物车控制器
 * @since 1.0
 * @version 1.0
 * @author QinYoubin (qin.youbin@sccaptain.com.cn)
 */
@RestController
@RequestMapping("/shopping/cart")
public class ShoppingCartController {
  @Resource
  private ShoppingCartService shoppingCartService;
  
  @PostMapping("/add")
  public JsonResult add(@RequestBody GWC gwc) {
    // 新增购物车信息
    return ControllerUtil.getResult(shoppingCartService.add(gwc));
  }
  @GetMapping("/list/{id}")
  public JsonResult list(@PathVariable String id) {
    // 查询用户购物车
    return JsonResult.success(shoppingCartService.list(id));
  }
  @GetMapping("/remove/{id}")
  public JsonResult remove(@PathVariable String id) {
    // 移除商品
    return ControllerUtil.getResult(shoppingCartService.remove(id));
  }
  @GetMapping("/getUserCartNum/{id}")
  public JsonResult getUserCartNum(@PathVariable String id) {
	  return JsonResult.success(shoppingCartService.getUserCartNum(id));
  }
}
